//#pragma comment(linker,"/STACK:16777216") /*16Mb*/
//#pragma comment(linker,"/STACK:33554432") /*32Mb*/
#define _CRT_SECURE_NO_DEPRECATE
#include<iostream>
#include<numeric>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<memory>
#include<string>
#include<vector>
#include<cctype>
#include<list>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
using namespace std;

typedef unsigned long long      ui64;
typedef long long               i64;
typedef	vector<int>             VI;
typedef	vector<bool>            VB;
typedef	vector<VI>              VVI;
typedef	vector<string>          VS;
typedef	pair<int,int>           PII;
typedef map<string,int>         MSI;
typedef set<int>                SI;
typedef set<string>             SS;
typedef map<int,int>            MII;
typedef	pair<double,double>     PDD;

#define PB                      push_back
#define MP                      make_pair
#define X                       first
#define Y                       second
#define FOR(i, a, b)            for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)           for(int i = (a) - 1; i >= (b); --i)
#define CLEAR(a, b)             memset(a, b, sizeof(a))
#define SZ(a)                   int((a).size())
#define ALL(a)                  (a).begin(), (a).end()
#define RALL(a)                 (a).rbegin(), (a).rend()
#define INF                     (2000000000)

int dist(PII a,PII b) {
	return (abs(a.X-b.X) + abs(a.Y-b.Y));
}

PII A,B;
vector<PII> v;
int minD(PII C) {
	int res = INF;
	FOR(i,0,SZ(v))
		res = min( res, dist(C,v[i]) );
	return res;
}

int n,m,l;
int solve(PII C) {
	// check if we can reach point A	
	if( C == B )
		return -1;
	int d1 = dist(C,A);
	int d2 = minD(C);
	if( (C.X == A.X && A.X == B.X && (A.X - B.X) * (C.X - B.X) < 0) ||
		(C.Y == A.Y && A.Y == B.Y && (A.Y - B.Y) * (C.Y - B.Y) < 0) )
		d2 += 2;

	if( d1 + d2 > l )
		return -1;
	if( n==1 ) {
		if( (A.Y - B.Y) * (C.Y - B.Y) >= 0 )
			return d2;
		else
			return -1;
	}
	if( m==1 ) {
		if( (A.X - B.X) * (C.X - B.X) >= 0 )
			return d2;
		else
			return -1;
	}
	return d2;
}

int main()
{
	cin >> n >> m >> l;
	cin >> A.X >> A.Y >> B.X >> B.Y;
	A.X--;
	A.Y--;
	B.X--;
	B.Y--;
	if( B.X > 0)
		v.PB( MP(B.X-1,B.Y) );
	if( B.X < n-1 )
		v.PB( MP(B.X+1,B.Y) );
	if( B.Y > 0 )
		v.PB( MP(B.X,B.Y-1) );
	if( B.Y < m-1 )
		v.PB( MP(B.X,B.Y+1) );
	// A - knight
	// B - deamon
	int ans = -1;
	FOR(i,max(0,B.X-1),min(B.X+2,n))
		FOR(j,0,m) 
			ans = max( ans, solve(MP(i,j)));

	FOR(i,max(0,B.Y-1),min(B.Y+2,m))
		FOR(j,0,n) 
			ans = max( ans, solve(MP(j,i)));
	cout << ans+1<< endl;
    return 0;
}